package com.vietnam.power.admin.controller;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.vietnam.power.service.CacheService;

@Controller
@RequestMapping("/admin")
public class CacheController {
	@Autowired
	private CacheService cacheService;
	
	private static Logger logger = Logger.getLogger(CacheController.class);
	
	@RequestMapping(value = "/clearCache", method = RequestMethod.GET)
	public ModelAndView clearCache() {
		ModelAndView mav = new ModelAndView("admin/homepage");
		
		logger.debug("Clear cache and return to home page");
		cacheService.clearAllCache();
		logger.debug("Done");
		mav.addObject("pageTitle", "Trang chu");
		return mav;
	}
}
